home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 43
/
Aminet 43 (2001)(GTI - Schatztruhe)[!][Jun 2001].iso
/
Aminet
/
comm
/
tcp
/
rxsocket.lha
/
rxsocket
/
examples
/
dsfun.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
2001-03-01
|
2KB
|
53 lines
/*
single connection handler for the ds service, see ds.rexx
*/
call initGlobal
call getSocket
call logConnection
call handle
exit
/***************************************************************************/
initGlobal: procedure expose global.
global.prg=ProgramName()
call SysLogCtl(global.prg)
global.verbose=GetVar("VERBOSE","LOCAL")
if global.verbose="" then global.verbose=0
return
/***************************************************************************/
getSocket: procedure expose global.
global.sock=LastSocket()
if global.sock==-1 then do
call EasyRequest(global.prg "can only be started by ds with RXSCall",global.prg)
exit
end
return
/***************************************************************************/
handle: procedure expose global.
sel.read.0=global.sock
res = WaitSelect("SEL",10,0,2**12)
if res<0 then call err "err wait %m"
if res=0 then call err "timeout ("global.peer")"
if recv(global.sock,"BUFF",256)<0 then call err "error recv %m"
date=formatdate(,"%a, %d %b %Y %X")
if send(global.sock,date)<0 then call err "error send %m"
return
/***************************************************************************/
err: procedure expose global.
parse arg msg
if global.verbose then call SysLog(msg,"ERR")
exit
/***************************************************************************/
info: procedure expose global.
parse arg msg
if global.verbose then call SysLog(msg,"INFO")
return
/***************************************************************************/
logConnection: procedure expose global.
if GetPeerName(global.sock,"GLOBAL")<0 then call err "can't get peer info %m"
global.peer="<"global.addrAddr":"global.addrPort">"
if global.verbose then call info "connection from" global.peer
return
/***************************************************************************/